﻿<%@ Page Title="Quản lý bảng giá theo lộ trình" MasterPageFile="~/Admin/Site.Master"
    Language="C#" AutoEventWireup="true" CodeBehind="QLBangGiaTheoLoTrinhAdmin.aspx.cs"
    Inherits="Transport.Admin.QLBangGiaTheoLoTrinhAdmin" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<%
if (Session["loainguoidung"] == null)
    {
        Response.Redirect("../Default.aspx");
    }
    else
    {
        if (Session["loainguoidung"].ToString() != "ADMIN")
            Response.Redirect("Default.aspx");
    }  
    %>
    <p>
        <b>Biển số:</b>
        <asp:TextBox ID="txt_BienSo" runat="server"></asp:TextBox>
        <asp:Button ID="btn_Search" runat="server" Text="Tìm" />
    </p>
    <p>
        <b>Lộ trình:</b>
        <asp:DropDownList ID="ddl_LT" runat="server" AutoPostBack="True" DataSourceID="EntityDataSource_LoTrinh"
            DataTextField="ten_lo_trinh" DataValueField="ma_lo_trinh" AppendDataBoundItems="true">
            <asp:ListItem Text="Select All" Value="-1" />
        </asp:DropDownList>
        <asp:EntityDataSource ID="EntityDataSource_LoTrinh" runat="server" ConnectionString="name=transportEntities"
            DefaultContainerName="transportEntities" EnableFlattening="False" EntitySetName="lo_trinh">
        </asp:EntityDataSource>
    </p>
    <div style="zoom: 1; overflow: auto;">
        <asp:GridView ID="GridView_Price" runat="server" AutoGenerateColumns="False" DataKeyNames="ma_bien_so,ma_lo_trinh"
            DataSourceID="EntityDataSource_Price" AllowPaging="True" CellPadding="4" CellSpacing="4"
            ForeColor="#333333" GridLines="None">
            <AlternatingRowStyle BackColor="White" />
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                <asp:BoundField DataField="ma_bien_so" HeaderText="Biển số" ReadOnly="True" SortExpression="ma_bien_so" />
                <asp:TemplateField HeaderText="Lộ trình">
                    <ItemTemplate>
                        <asp:DropDownList ID="ddl_uLT" runat="server" DataSourceID="EntityDataSource_LoTrinh"
                            DataTextField="ten_lo_trinh" DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                        </asp:DropDownList>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:DropDownList ID="ddl_uLT1" runat="server" DataSourceID="EntityDataSource_LoTrinh"
                            DataTextField="ten_lo_trinh" DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                        </asp:DropDownList>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="gia_tien" HeaderText="Giá tiền" SortExpression="gia_tien" />
                <asp:BoundField DataField="chi_phi_vuot_km" HeaderText="Chi phí vượt km" SortExpression="chi_phi_vuot_km" />
            </Columns>
            <FooterStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
            <HeaderStyle BackColor="#7FB308" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="#7FB308" ForeColor="#333333" HorizontalAlign="Center" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
            <SortedAscendingCellStyle BackColor="#FDF5AC" />
            <SortedAscendingHeaderStyle BackColor="#4D0000" />
            <SortedDescendingCellStyle BackColor="#7FB308" />
            <SortedDescendingHeaderStyle BackColor="#820000" />
        </asp:GridView>
        <asp:EntityDataSource ID="EntityDataSource_Price" runat="server" ConnectionString="name=transportEntities"
            DefaultContainerName="transportEntities" EnableDelete="True" EnableFlattening="False"
            EnableInsert="True" EnableUpdate="True" EntitySetName="bang_gia_theo_lo_trinh"
            Where="it.ma_lo_trinh = CASE WHEN @MaLT = '-1' THEN  it.ma_lo_trinh ELSE @MaLT END">
            <WhereParameters>
                <asp:ControlParameter ControlID="ddl_LT" Type="String" Name="MaLT" PropertyName="SelectedValue" />
            </WhereParameters>
        </asp:EntityDataSource>
        <asp:QueryExtender ID="qeSearch" runat="server" TargetControlID="EntityDataSource_Price">
            <asp:SearchExpression DataFields="ma_bien_so" SearchType="Contains">
                <asp:ControlParameter ControlID="txt_BienSo" />
            </asp:SearchExpression>
            <asp:OrderByExpression DataField="ma_bien_so" Direction="Ascending" />
        </asp:QueryExtender>
    </div>
    <p>
        <asp:DetailsView ID="DetailsView_Price" runat="server" Height="50px" Width="125px"
            AutoGenerateRows="False" DataKeyNames="ma_bien_so,ma_lo_trinh" DataSourceID="EntityDataSource_Price"
            BackColor="White" BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px"
            CellPadding="4" FieldHeaderStyle-Wrap="false" DefaultMode="Insert" ForeColor="Black"
            GridLines="Horizontal" oniteminserted="DetailsView_Price_ItemInserted">
            <EditRowStyle BackColor="White" ForeColor="Black" />
            <Fields>
                <asp:BoundField DataField="ma_bien_so" HeaderText="Biển số" ReadOnly="True" SortExpression="ma_bien_so" />
                <asp:TemplateField HeaderText="Lộ trình">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddl_iLT" runat="server" DataSourceID="EntityDataSource_LoTrinh"
                            DataTextField="ten_lo_trinh" DataValueField="ma_lo_trinh" SelectedValue='<%# Bind("ma_lo_trinh") %>'>
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="gia_tien" HeaderText="Giá tiền" SortExpression="gia_tien" />
                <asp:BoundField DataField="chi_phi_vuot_km" HeaderText="Chi phí vượt km" SortExpression="chi_phi_vuot_km" />
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
            <FooterStyle BackColor="#CCCC99" ForeColor="Black" />
            <HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
            <PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
        </asp:DetailsView>
    </p>
</asp:Content>
